<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
</html>
<script>
  function gohome(money) {
    var m = 1;
    var sum = 0;
    for (let i = 1; sum < money; i++) {
      if (i > 1) {
        m = m + 2; //每天的钱多2元
      }
      sum = m + sum; //每天的钱累加
    //   console.log("需要多少天：", i, "每天的钱：", m, "总共多少钱", sum);
      if (sum >= money) {
        console.log(i);
      }
    }
  }
  gohome(1);
</script>
